/**
 * 文件名称：MeasurementAction.java
 * 文件版权：ChinaParasol Technologies Co., Ltd. Copyright 2000-2020,  All rights reserved
 * 文件描述：<描述>
 * 创建作者：Administrator
 * 创建时间：Jan 5, 2013
 * 修改内容：<修改内容>
 */
package com.parasol.hcerp.service.measurement.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.parasol.hcerp.common.action.ParasolAction;
import com.parasol.hcerp.service.measurement.domain.MeasurementBean;
import com.parasol.hcerp.service.measurement.service.MeasurementService;

/**
 * 
 * @author  Administrator
 * @version V1.0, Jan 5, 2013
 */
public class MeasurementAction extends ParasolAction
{
    
    /** 注释内容 */
    private static final long serialVersionUID = 4202624407089923648L;
    
    private MeasurementService measurementService = null;
    
    private MeasurementBean measurementBean = null;
    
    private String measurementid = null;
    
    public MeasurementBean getMeasurementBean()
    {
        return measurementBean;
    }
    
    public void setMeasurementBean(MeasurementBean measurementBean)
    {
        this.measurementBean = measurementBean;
    }
    
    public MeasurementService getMeasurementService()
    {
        return measurementService;
    }
    
    public void setMeasurementService(MeasurementService measurementService)
    {
        this.measurementService = measurementService;
    }
    
    public String queryForList()
    {
        super.clientCache();
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementList", measurementList);
        return SUCCESS;
    }
    
    public String saveForJump()
    {
        super.clientCache();
        return SUCCESS;
    }
    
    public String saveForMeasurement()
    {
        super.clientCache();
        int result = measurementService.checkExist(measurementBean.getMeasurementname());
        if (result > 0)
        {
            HttpServletRequest request = super.getRequest();
            request.setAttribute("errorMessage", "该计量单位已经存在");
        }
        
        measurementService.saveForMeasurement(measurementBean);
        
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementList", measurementList);
        return SUCCESS;
    }
    
    public String updateForJump()
    {
        super.clientCache();
        measurementBean = measurementService.queryForMeasurement(measurementid);
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementBean", measurementBean);
        return SUCCESS;
    }
    
    public String updateForMeasurement()
    {
        super.clientCache();
        int result = measurementService.checkExist(measurementBean.getMeasurementname());
        if (result > 0)
        {
            HttpServletRequest request = super.getRequest();
            request.setAttribute("errorMessage", "该计量单位已经存在");
            
            measurementBean = measurementService.queryForMeasurement(measurementid);
            request.setAttribute("measurementBean", measurementBean);
        }
        
        measurementService.updateForMeasurement(measurementBean);
        
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementList", measurementList);
        return SUCCESS;
    }
    
    public String deleteForMeasurement()
    {
        super.clientCache();
        measurementService.deleteForMeasurement(measurementid);
        
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementList", measurementList);
        return SUCCESS;
    }
    
    public String showForMeasurement()
    {
        super.clientCache();
        measurementBean = measurementService.queryForMeasurement(measurementid);
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementBean", measurementBean);
        return SUCCESS;
    }
    
    
    public String selectMeasurement()
    {
        super.clientCache();
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        HttpServletRequest request = super.getRequest();
        request.setAttribute("measurementList", measurementList);
        return SUCCESS;
    }
    
    public String getMeasurementid()
    {
        return measurementid;
    }
    
    public void setMeasurementid(String measurementid)
    {
        this.measurementid = measurementid;
    }
    
}
